<template>
	<view>
		<htz-signature ref='sign' @sumbit="sumbit"  @fail="fail" cid="ceshi1"></htz-signature>
	</view>
</template>

<script>
	import htzSignature from '@/components/htz-signature/htz-signature.vue'
	export default {
		data() {
			return {
				toJSON: '',
				type: ''
			}
		},
		onLoad(options) {
			console.log(this.$refs.sign)
			if(options.type) {
				this.type = options.type
			}
			let context = uni.createCanvasContext('ceshi1')
			context.fillStyle = "#fff";
			context.fillRect(0, 0, this.$refs.sign.width, this.$refs.sign.height);

		},
		components: {
			htzSignature
		},
		methods: {
			sumbit(res){
				console.log('sumbit',res)
				try {
					uni.showLoading({
						title: '提交中',
						mask: true
					})
					let key = this.type ? this.type : 'ceshiUrl'
					
				    uni.setStorageSync(key, res.tempFilePath);
					
					uni.navigateBack();
				} catch (e) {
				    // error
				}
			},
			fail(err){
				console.log('fail',err)
			}
		},
		toJSON() {}
	}
</script>

<style>

</style>
